package com.yuntsg.nnsfcp.test.pdf.asposepdf.examples.AsposePdfExamples.Pages;

import com.aspose.pdf.BackgroundArtifact;
import com.aspose.pdf.Document;
import com.aspose.pdf.Page;

import java.io.FileInputStream;

public class AddImageAsPageBackground {

    public static void main(String[] args) throws Exception {
        String myDir = "PathToDir";
        // Create a new Document object
        Document doc = new Document();
        // Add a new page to document object
        Page page = doc.getPages().add();
        // Create BackgroundArtifact object
        BackgroundArtifact background = new BackgroundArtifact();
        // Specify the image for backgroundartifact object
        background.setBackgroundImage(new FileInputStream(myDir + "logo.png"));
        // Add backgroundartifact to artifacts collection of page
        page.getArtifacts().add(background);
        // Save the document
        doc.save(myDir + "BackGround.pdf");
    }
}
